package com.hqyj.springCloundWeb.controller;

import com.hqyj.test.entity.City;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.io.Resource;
import org.springframework.core.io.UrlResource;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.util.ResourceUtils;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;

import javax.servlet.http.HttpServletRequest;
import java.io.File;
import java.io.IOException;
import java.util.List;
import java.util.ArrayList;
import java.util.stream.Collectors;

@Controller
@RequestMapping("/test")
public class TestController {


    /**
     * 127.0.0.1:8081/test/vueTest
     * @return
     */
    @GetMapping("/vueTest")
    public String vueTestPage(){
        return "index";
    }




    /**
     * 127.0.0.1:8081/test/thymeleafTest
     * @param modelMap
     * @return
     */
    @GetMapping("/thymeleafTest")
    public  String thymeleafTestPage(ModelMap modelMap) {
//        int i = 1/0;
       List<City> cities = new ArrayList<>();
        modelMap.addAttribute("message","Hello");
        modelMap.addAttribute("checked",true);
        modelMap.addAttribute("currentNumber",95);
//        modelMap.addAttribute("src","https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fup.enterdesk.com%2Fphoto%2F2012-3-2%2Fenterdesk.com-B526ECADD33DBD367676A93E051BA1EC.jpg&refer=http%3A%2F%2Fup.enterdesk.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1663575127&t=13774936ccb4ad7abc63fef6a86cd3aa");
        modelMap.addAttribute("src","/images/test.jpg");
        modelMap.addAttribute("href","http://www.baidu.com");
        modelMap.addAttribute("city",new City());
        modelMap.addAttribute("cities",cities);
//        modelMap.addAttribute("template","test/thymeleafTest");


//        return "test/thymeleafTest";
//        返回碎片组装器
        return "index";
    }


}
